home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / module-init-tools < prev    next >
Text File  |  2008-10-14  |  1KB  |  66 lines

  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          module-init-tools
  4. # Required-Start:    
  5. # Required-Stop:     
  6. # Should-Start:      checkroot
  7. # Should-stop:
  8. # Default-Start:     S
  9. # Default-Stop:
  10. # Short-Description: Process /etc/modules.
  11. # Description:       Load the modules listed in /etc/modules.
  12. ### END INIT INFO
  13.  
  14. # Silently exit if the kernel does not support modules or needs modutils.
  15. [ -f /proc/modules ] || exit 0
  16. [ ! -f /proc/ksyms ] || exit 0
  17. [ -x /sbin/modprobe  ] || exit 0
  18.  
  19. . /etc/default/rcS
  20. . /lib/lsb/init-functions
  21.  
  22. PATH="/sbin:/bin"
  23.  
  24. KVER=$(uname -r)
  25. KMAJ=${KVER%${KVER#*.*[^.]}}
  26. KMAJ=${KMAJ%.}
  27.  
  28. if [ -e /etc/modules-$KVER ]; then
  29.   MODULES_FILE=/etc/modules-$KVER
  30. elif [ -e /etc/modules-$KMAJ ]; then
  31.   MODULES_FILE=/etc/modules-$KMAJ
  32. else
  33.   MODULES_FILE=/etc/modules
  34. fi
  35.  
  36. load_module() {
  37.   local module args
  38.   module="$1"
  39.   args="$2"
  40.  
  41.   if [ "$VERBOSE" != no ]; then
  42.     log_action_msg "Loading kernel module $module"
  43.     modprobe $module $args || true
  44.   else
  45.     modprobe $module $args > /dev/null 2>&1 || true
  46.   fi    
  47. }
  48.  
  49. if [ "$VERBOSE" = no ]; then
  50.   log_action_begin_msg 'Loading kernel modules'
  51. fi
  52.  
  53. # Loop over every line in /etc/modules.
  54. log_begin_msg 'Loading manual drivers...'
  55. grep '^[^#]' $MODULES_FILE | \
  56. while read module args; do
  57.   [ "$module" ] || continue
  58.   load_module "$module" "$args"
  59. done
  60.  
  61. if [ "$VERBOSE" = no ]; then 
  62.   log_action_end_msg 0
  63. fi
  64.  
  65. exit 0
  66.